package sjtu.ist.warehouse4ws.service;

import java.util.List;

import sjtu.ist.warehouse4ws.dao.RoleEpcDao;
import sjtu.ist.warehouse4ws.dao.RoleEpcDaoHibernate;
import sjtu.ist.warehouse4ws.dao.cust.CustRoleEpcDao;
import sjtu.ist.warehouse4ws.model.CustRoleEpc;
import sjtu.ist.warehouse4ws.model.RoleEpc;
import sjtu.ist.warehouse4ws.tool.Constants;
import sjtu.ist.warehouse4ws.tool.PropertyHelper;

public class RoleEpcServiceImpl implements RoleEpcService{
	private RoleEpcDao roleEpcDao;
	private CustRoleEpcDao custRoleEpcDao;

	public void setRoleEpcDao(RoleEpcDao roleEpcDao) {
		this.roleEpcDao = roleEpcDao;
	}

	public void setCustRoleEpcDao(CustRoleEpcDao custRoleEpcDao) {
		this.custRoleEpcDao = custRoleEpcDao;
	}

	@Override
	public void save(RoleEpc roleEpc, int companyId) {
		// TODO Auto-generated method stub
		if(companyId==Constants.ADMIN_COMPANY_ID){
			roleEpcDao.save(roleEpc);
		}else{
			CustRoleEpc cre=new CustRoleEpc();
			PropertyHelper.copyProperties(roleEpc, cre);
			custRoleEpcDao.save(cre);
		}		
	}

	@Override
	public List find(String uid) {
		// TODO Auto-generated method stub
		return roleEpcDao.find(uid);
	}	
}
